//@ts-ignore
import { requestHttp } from "@/utils/requestHttp.ts";

//引入类型约束
import { responseCategoryListData } from "./type.ts";
import type { categoryType } from "./type.ts";
/**
 * 查询商品分类信息(支持分页查询) get请求
 * page=1
 * pageSize=3
 */
export const reqCommodityCategoryList = (page:number = 1, pageSize:number = 3) => {
    return requestHttp<responseCategoryListData>({
        url:"/manage/category",
        method:"get",
        params:{
            page:page,
            pageSize:pageSize
        }
    })
}

/**
 * 添加一条商品分类  post
 * 请求体 = {categoryName:""}
 */
export const reqSaveCommodityCategory = (categoryName:string) => {
    return requestHttp({
        url:"/manage/category",
        method:"post",
        data:{
            categoryName:categoryName
        }
    })
}

/**
 * 修改一条商品分类  put
 * 请求体 = {categoryName:""}
 */
 export const reqUpdateCommodityCategory = (categoryInfo:any) => {
    return requestHttp({
        url:"/manage/category",
        method:"put",
        data:{
            categoryId:categoryInfo.categoryId,
            categoryName:categoryInfo.categoryName
        }
    })
}

/**
 * 删除一条商品分类  delete
 * categoryId = ?
 */
 export const reqDeleteCommodityCategory = (categoryId:number) => {
    return requestHttp({
        url:"/manage/category",
        method:"delete",
        params:{
            categoryId:categoryId
        }
    })
}

/**
 * 批量删除商品分类 delete
 * requestBody = number[categoryId]
 */
export const reqDeleteCommodityCategoryBatch = (categoryIds:number[]) => {
    return requestHttp({
        url:"/manage/category/batch",
        method:"delete",
        data:categoryIds
    })
}